<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //对象简写
      // let name = 'lipan'
      // let age = 12
      // const obj = {
      //     //简写的内容放前面
      //     name,
      //     age,
      //     //普通函数简写
      //     useName(){
      //         console.log('haha')
      //     }
      // }
      // console.log(obj)

      //对象的解构赋值
      let age = 19
      const obj = {
        name: 'hah',
        age: '18',
        address: { area: 'houriui', number: '123' },
      };
      let {
        name,
        age:myage,  //属性名：别名
        address: { number, area }, //深层结构
      } = obj;

      //对数组进行结构
      const family = ['猪爸爸','猪妈妈','佩奇','乔治']
      let [father,mother,,qiaozhi] =family
      console.log(father)
      console.log(mother)
      console.log(qiaozhi)
      let[,,...son] = family
      console.log(son)

      //互换位置
      let a = 100;
      let b = 200;
      [a,b] =[b,a]
      console.log(a,b)
    </script>
  </body>
</html>
